import express from 'express';
import { GradeController } from '../controllers/gradeController.js';
import { authenticateToken } from '../middleware/auth.js';
import { upload } from '../middleware/upload.js';

const router = express.Router();
const gradeController = new GradeController();

// 下载成绩导入模板
router.get('/template', gradeController.downloadTemplate.bind(gradeController));

// 导入成绩数据
router.post('/import', upload.single('file'), gradeController.importGrades.bind(gradeController));

// 获取成绩列表
router.get('/', gradeController.getGrades.bind(gradeController));

// 获取成绩统计
router.get('/stats', gradeController.getGradeStats.bind(gradeController));

// 获取学生个人成绩
router.get('/student/:studentId', gradeController.getStudentGrades.bind(gradeController));

// 创建成绩记录
router.post('/', gradeController.createGrade.bind(gradeController));

// 更新成绩记录
router.put('/:id', gradeController.updateGrade.bind(gradeController));

// 删除成绩记录
router.delete('/:id', gradeController.deleteGrade.bind(gradeController));

export default router;